import React, { Component } from 'react';

// 异步加载组件
class AsyncPage extends Component {
  state = {
    Foo: null
  };

  componentWillMount() {
    import('../../../../components/layout/Foo').then(Foo => {
      this.setState({ Foo: Foo.default });
    });
  }

  render() {
    let {Foo} = this.state;
    if (!Foo) {
      return <div>Loading...</div>;
    } else {
      return (
        <div>
          <h2>AsyncPage</h2>
          <Foo/>
        </div>
      );
    }
  }
}

export default AsyncPage;
